package com.cms.biz.products;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.cms.bean.ProductBean;
import com.cms.bean.ProductPicBean;

public class ProductHelper {
	
	public static void AddProduct(Connection conn,ProductBean pBean){
		PreparedStatement pst=null;
		try {
			pst = conn.prepareStatement(SQLString.ADD_PRODUCT);
			pst.setInt(1, pBean.getId());
			pst.setInt(2, pBean.getFolderId());
			pst.setString(3, pBean.getTitle());
			pst.setInt(4, pBean.getCategoryId());
			pst.setInt(5, pBean.getSubCategoryId());
			pst.setInt(6, pBean.getSpecialId());
			pst.setInt(7, pBean.getPicNum());
			pst.setInt(8, pBean.getCount());
			pst.setInt(9, pBean.getIspassd());
			pst.setString(10, pBean.getCreateUser());
			pst.execute();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally{
			if (pst != null) {
				try {
					pst.close();
					pst = null;
				} catch (final SQLException e) {
				}
			}
		}
	} 
	
	public static void AddProductPicture(Connection conn,ProductPicBean pBean){
		PreparedStatement pst=null;
		try {
			pst = conn.prepareStatement(SQLString.ADD_PRODUCT_PICTURE);
			pst.setInt(1, pBean.getId());
			pst.setInt(2, pBean.getParentId());
			pst.setString(3, pBean.getSuffix());
			pst.setString(4, pBean.getFileName());
			pst.setString(5, pBean.getCreateUser());
			pst.execute();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally{
			if (pst != null) {
				try {
					pst.close();
					pst = null;
				} catch (final SQLException e) {
				}
			}
		}
	}

}
